home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Source Code / Zoners Half-Life Tools / common / TimeCounter.h < prev    next >
C/C++ Source or Header  |  2000-09-14  |  721b  |  49 lines

  1. #ifndef TIMECOUNTER_H__
  2. #define TIMECOUNTER_H__
  3.  
  4. #if _MSC_VER >= 1000
  5. #pragma once
  6. #endif
  7.  
  8. #include "cmdlib.h"
  9.  
  10. class TimeCounter
  11. {
  12. public:
  13.     void start()
  14.     {
  15.         start = I_FloatTime();
  16.     }
  17.  
  18.     void stop()
  19.     {
  20.         double stop = I_FloatTime();
  21.         accum += stop - start;
  22.     }
  23.  
  24.     double getTotal() const
  25.     {
  26.         return accum;
  27.     }
  28.  
  29.     void reset()
  30.     {
  31.         memset(this, 0, sizeof(*this));
  32.     }
  33.  
  34. // Construction
  35. public:
  36.     TimeCounter()
  37.     {
  38.         reset();
  39.     }
  40.     // Default Destructor ok
  41.     // Default Copy Constructor ok
  42.     // Default Copy Operator ok
  43.  
  44. protected:
  45.     double start;
  46.     double accum;
  47. };
  48.  
  49. #endif//TIMECOUNTER_H__